<body class="app" data-ad="true">

<section class="app-content">
	<section class="page page-index noline" data-plugin-type="info_front">

      <div class="pay-type bw mt20">
            <label><button style="width:210px; height:50px; border-radius: 15px;background-color:#FE6714; border:0px #FE6714 solid; cursor: pointer;  color:white;  font-size:16px;" type="button" 
            name="p-type" value="wx" onclick="callpay()">微信支付</button></label>
      </div>

	</section>

    <!-- 底部menu-->
    <?php echo $this->partial('public/menu.phtml'); ?>
</section>

<script type="text/javascript">

//调用微信JS api 支付
function jsApiCall()
{
	WeixinJSBridge.invoke(
		'getBrandWCPayRequest',
		<?php echo $this->jsApiParameters; ?>,
		function(res){
			WeixinJSBridge.log(res.err_msg);
			if(res.err_msg == "get_brand_wcpay_request:ok" ) {
				 window.location.href="<?php echo $this->url('order', array('action'=>'paymentDone'));?>"; 
			} else {
				alert('支付失败，请重新支付');
			}          
		}
	);
}

function callpay()
{
	<?php if($this->error_code == 'ORDERPAID') {?>
		alert('该订单已支付');
		return false;
	<?php }?>
	if (typeof WeixinJSBridge == "undefined"){
	    if( document.addEventListener ){
	        document.addEventListener('WeixinJSBridgeReady', jsApiCall, false);
	    }else if (document.attachEvent){
	        document.attachEvent('WeixinJSBridgeReady', jsApiCall); 
	        document.attachEvent('onWeixinJSBridgeReady', jsApiCall);
	    }
	}else{
	    jsApiCall();
	}
}
</script>
